from django.db import models
from utils.basemodel import BasaModel
# Create your models here.
class CateCakeModel(BasaModel):
    cname = models.CharField(max_length=15,verbose_name="类型")
    class Meta:
        db_table = "catecakes"
    def __str__(self):
        return self.cname
class TasteCakeModel(BasaModel):
    cname = models.ForeignKey(CateCakeModel,on_delete=models.CASCADE,verbose_name="所属类型")
    tname = models.CharField(max_length=15,verbose_name="口味")
    class Meta:
        db_table = "tastecakes"
    def __str__(self):
        return self.tname
class CakesModel(BasaModel):
    kname = models.CharField(max_length=20,verbose_name="蛋糕名称")
    cate = models.ForeignKey(CateCakeModel, on_delete=models.CASCADE,verbose_name="所属类型")
    taste = models.ForeignKey(TasteCakeModel,on_delete=models.CASCADE,verbose_name="所属口味")
    price = models.IntegerField(verbose_name="商品单价")
    weight = models.IntegerField(verbose_name="商品重量（磅）")
    cover = models.ImageField(upload_to="uploads",blank=True,null=True,verbose_name="商品图片")
    intro = models.CharField(max_length=255,default="暂无",verbose_name="课程简介")
    quality  =models.IntegerField(verbose_name="质量",null=True,default=0)
    kw = models.CharField(max_length=20,verbose_name="口味",null=True,default=0)
    td = models.CharField(max_length=50,verbose_name="甜度",null=True,default=0)
    kg = models.CharField(max_length=50,verbose_name="口感",null=True,default=0)
    zucang = models.CharField(max_length=50,verbose_name="贮藏条件",null=True,default=0)
    limg  = models.ImageField(upload_to="uploads",blank=True,null=True,verbose_name="商品图片2")
    class Meta:
        db_table = "product"
        verbose_name_plural = "蛋糕"
    def __str__(self):
        return self.kname
class BannerModel(BasaModel):
    title = models.CharField(max_length=50,verbose_name="标题")
    fimg = models.ImageField(upload_to="uploads",verbose_name="图片")
    link = models.CharField(max_length=200,verbose_name="链接",default="#")
    ishttp = models.BooleanField(default=False,verbose_name="是否是http链接")
    class Meta:
        db_table = 'banner'

    def __str__(self):
        return self.title


